package com.example.source.spring.transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import org.springframework.transaction.annotation.Transactional;
import java.util.List;

@Service
public class TransactionalService {
    @Autowired
    PersonMapper personMapper;

    @Transactional
    public int add(Person person){
        System.out.println(person);
        System.out.println(1/0);
        return personMapper.insert(person);
    }

    @Transactional
    public List<Person> get(){
        return personMapper.selectAll();
    }

}
